from tkinter.simpledialog import *
from tkinter import *

root = Tk()
root.geometry('300x200')

var = StringVar()
def test1():
    a = askinteger(title='输入你的年龄',prompt='你的年龄',initialvalue=18,minvalue=1,maxvalue=150)
    print(a)
    var.set(a)
    


Button(root,text='年龄',command=test1).pack()
show = Label(root,width=40,height=3,bg='green',textvariable=var).pack()

root.mainloop()